package com.phospherus.user.repository

import com.phospherus.common.repository.BaseRepository
import com.phospherus.user.entity.Resource
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.query.Param

/**
 * @author songjinlong
 * @version 1.0
 * @since 2017/11/30
 */
interface ResourceRepository : BaseRepository<Resource, Long> {
    @Query("select r.* from role_user ru,role_resource rr,resource r where ru.user_id= :userId and rr.role_id=ru.role_id and r.id=rr.resource_id", nativeQuery = true)
    fun getResourcesByUserId(@Param("userId") userId: Long?): List<Resource>?
}